import java.lang.Math;

public class ThreadSleepRunnableTest
{
    public static void main(String[] args)
    {
        TestThread2 t2 = new TestThread2();

        new Thread(t2, "Thread0").start();
        new Thread(t2, "Thread1").start();
        new Thread(t2, "Thread2").start();
    }
}

class TestThread2 extends Thread
{
    private int sleepTime;

    public TestThread2()
    {
        sleepTime = (int)(Math.random() * 6000);
    }

    @Override
    public void run()
    {
        System.out.println(getName() + "going to sleep for " + sleepTime + "ms");

        try
        {
            Thread.sleep(sleepTime);
        }
        catch(InterruptedException i)
        {
            i.printStackTrace();
        }

        System.out.println(getName() + " finished");
    }
}
